<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2014 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: Dean <zxxjjforever@163.com>
// +----------------------------------------------------------------------
namespace app\goods\home;//Demo插件英文名，改成你的插件英文就行了
use app\base\controller\Base;
use app\goods\model\HomeGoods;
class Index extends Base
{
	// token = 823221dcc53820f4e9cfbb7f68355c37
	// projectId = 66
    function __construct(){
        parent::__construct();
        $this->Model=new HomeGoods();
    }
    public function search()
    {
        $condition = $this->vdong('condition');
        $field = $request->header('field');
        // 分页
        $page = $this->vdongPage();
        $page_size =$page['size'];
        $page_number = $page['page_number'];

        $config = array(
            'page' => $page_number
            );
        $result = DB::name('goods_goods')
            ->field($field)
            ->where('name','like',"%$condition['name']%")
            ->where('projectid',$condition['projectid'])
            ->where('status',1)
            ->where('isdel',2)
            ->order(input('order'))
            ->paginate($page_size,false,$config)->toArray();
        outFormats($result['data'], '请求成功！','',$result['current_page'],$result['total']);
    	
    }
    public function vdong($name) {
        $param = input();
        $array = $param[$name];
      return $array;
    }
    public function vdongPage()
    {
        $param = input();
        $array = $param['page'];
      return $array;
    }
}
